//
//  FinishedSuCell.m
//  RRQS
//
//  Created by kyjun on 16/3/29.
//
//

#import "FinishedSuCell.h"

@interface FinishedSuCell ()

@property(nonatomic,strong) UIButton* btnIcon;
@property(nonatomic,strong) UILabel* labelContent;

@end

@implementation FinishedSuCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        
        [self layoutUI];
        [self layoutConstraints];
    }
    return self;
}

#pragma mark =====================================================  user interface layout
-(void)layoutUI{
    [self.contentView addSubview:self.btnIcon];
    [self.contentView addSubview:self.labelContent];
}

-(void)layoutConstraints{
    self.btnIcon.translatesAutoresizingMaskIntoConstraints = NO;
    self.labelContent.translatesAutoresizingMaskIntoConstraints = NO;
    
    [self.btnIcon addConstraint:[NSLayoutConstraint constraintWithItem:self.btnIcon attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25.f]];
    [self.btnIcon addConstraint:[NSLayoutConstraint constraintWithItem:self.btnIcon attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25.f]];
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:self.btnIcon attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0.f]];
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:self.btnIcon attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:10.f]];
   
    
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:self.labelContent attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.f]];
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:self.labelContent attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.btnIcon attribute:NSLayoutAttributeRight multiplier:1.0 constant:10.f]];
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:self.labelContent attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.f]];
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:self.labelContent attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0.f]];
    
     
}

#pragma mark =====================================================  property package
-(void)setGoodsName:(NSString *)goodsName{
    if(goodsName){
        _goodsName = goodsName;
        self.labelContent.text = goodsName;
    }
}

-(UIButton *)btnIcon{
    if(!_btnIcon){
        _btnIcon = [UIButton buttonWithType:UIButtonTypeCustom];
        [_btnIcon setImage:[UIImage imageNamed:@"icon-sendStatus-enter"] forState:UIControlStateNormal];
    }
    return _btnIcon;
}

-(UILabel *)labelContent{
    if(!_labelContent){
        _labelContent = [[UILabel alloc]init];
        _labelContent.font = [UIFont systemFontOfSize:14.f];
        _labelContent.numberOfLines = 0;
        _labelContent.lineBreakMode = NSLineBreakByCharWrapping;
    }
    return _labelContent;
}


@end
